package com.lionxing.DNTG;

import org.cocos2d.nodes.CCSprite;
import org.cocos2d.types.CGPoint;


public class Tile {
	
	int x, y, value, originalValue;
	CCSprite sprite;
    
    int x0, y0;
    
    public Tile(int posX, int posY)
    {
    	x = posX;
    	y = posY;
        x0 = posX;
        y0 = posY;
    	
    }
    
   public CGPoint getpixPostion()
    {
    	
	   return CGPoint.ccp(GameDefine.kStartX + x * GameDefine.kTileSize +GameDefine.kTileSize/2.0f,GameDefine.kStartY + y * GameDefine.kTileSize +GameDefine.kTileSize/2.0f);
	   
    }
   
   public void trade(Tile otherTile)
   {
	   
	   int tempValue = value;
	   
	   CCSprite tmpsp = this.sprite;
		this.sprite = otherTile.sprite;
		this.value = otherTile.value;
		otherTile.sprite = tmpsp;
		otherTile.value = tempValue;
	   
   }
   
   public boolean nearTile (Tile othertile)
   {
	   
	   
	   
	   return 
		(x0 == othertile.x0 && Math.abs(y0 - othertile.y0)==1)
		||
		(y0 == othertile.y0 && Math.abs(x0 - othertile.x0)==1);

   }

}
